package 基础.构造方法;


class Student{
    public String name;
    public int age;
    public String sex;

    Student(){

    }
    Student(String sex){
        this.sex = sex;
    }

    Student(String name,int age){
        this("男");//必须写第一行
        System.out.println("性别为男");
    }
    Student(String name,int age,String sex){
        this.age = age;
        this.name = name;
        this.sex =sex;
        System.out.println("姓名："+this.name+" 年龄："+this.age+" 性别："+this.sex);
    }


}
public class 构造方法 {
    public static void main(String[] args) {
        Student student = new Student();//一定是先开辟空间，在执行构造方法
        Student student1 =new Student("小明",12,"男");
        Student Student2  =new Student("小红",16);

    }
}
